src: decouple KeyObject and CryptoKey and move CryptoKey to src#62924
Closed
panva wants to merge 11 commits into
Closed
src: decouple KeyObject and CryptoKey and move CryptoKey to src#62924panva wants to merge 11 commits into
panva wants to merge 11 commits into
Conversation
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #62924 +/- ##
==========================================
- Coverage 89.65% 89.64% -0.01%
==========================================
Files 708 708
Lines 220402 220696 +294
Branches 42269 42358 +89
==========================================
+ Hits 197597 197852 +255
+ Misses 14671 14651 -20
- Partials 8134 8193 +59
🚀 New features to boost your workflow:
|
addaleax
reviewed
Apr 24, 2026
Member
Author
1d88d0c to
6843254
Compare
anonrig
reviewed
Apr 25, 2026
Member
Author
|
@anonrig https://github.com/nodejs/node/compare/684325443cbfc5b691465efde509c169c0a87401..db2a2fb8ead37ed8571fa96c5bd5444054556236 Also
Edit: now squashed back to its right place |
Member
Author
|
I'm going to autosquash the fixups to restore some notion of coherence when opening the individual commits. |
1ec62d4 to
9c37d26
Compare
aduh95
reviewed
Apr 29, 2026
aduh95
reviewed
Apr 29, 2026
aduh95
reviewed
Apr 29, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
This comment was marked as outdated.
This comment was marked as outdated.
c265dcb to
20a35c3
Compare
Member
Author
|
@aduh95 nits resolved (for real this time) For real real. |
Stores the Web Crypto `[[usages]]` slot as a native uint32 mask instead of a JS array. The public and internal usages arrays are now expanded lazily from the mask, while hot-path usage checks can test a bit without allocating or scanning an array. `internal/crypto/util` now derives usage masks from the canonical usage order and exposes helpers for mask conversion and membership checks. CryptoKey import/generation validation uses the zero mask for empty usages, and structured clone / worker transfer serialize the mask too. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Collaborator
Collaborator
panva
added a commit
that referenced
this pull request
May 3, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #62924 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Member
Author
|
Landed in 25f80fb |
aduh95
pushed a commit
that referenced
this pull request
May 5, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #62924 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This was referenced May 23, 2026
specs-compliance-issue: crypto.subtle.deriveKey implicit key leak on global Promise pollution
#59699
Closed
panva
added a commit
to panva/node
that referenced
this pull request
May 25, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62924 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
panva
added a commit
to panva/node
that referenced
this pull request
May 25, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62924 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
panva
added a commit
to panva/node
that referenced
this pull request
May 26, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62924 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
araujogui
pushed a commit
to araujogui/node
that referenced
this pull request
May 26, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: nodejs#62924 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors Node.js' Web Crypto
CryptoKeyimplementation to decouple it fromKeyObjectby movingCryptoKey's internal-slot storage into a new nativeNativeCryptoKeybase and updating internal crypto code to use slot accessors instead of JS-visible properties.Paired with a future EOL #62321 deprecation (v26.x runtime-deprecation, v27.x EOL) this makes non-extractable CryptoKey key material unreachable in userland 🎉 thanks to removing public access to the
[[handle]]internal slot.Changes:
NativeCryptoKey(C++) plus JS-side slot helpers (getCryptoKey{Type,Extractable,Algorithm,Usages,Handle}) and updates Web Crypto/internal consumers accordingly.KeyObjectwrappers toKeyObjectHandleusage, including structured-clone/worker-transfer support.The PR is squash-merged, but the changes are split into logical commits to make review tractable.
Commits
Each commit has a description covering its scope and rationale, see individual commit messages for details. Commits are cumulative (except for fixups and applying feedback). No later commit from the ones listed below revises code introduced by an earlier one. In order:
src: decouple KeyObject and CryptoKey and move CryptoKey to src(empty, just a squash target)src,crypto: add NativeCryptoKeylib,crypto: rewire CryptoKey on the native classlib,crypto: migrate algorithm modules to native CryptoKeysrc,crypto: relax RSA/EC keygen arg checkslib,crypto: validate HkdfParams info length earlylib,crypto: add early structural JWK validationtest: add CryptoKey class regression testsbenchmark: add Web Crypto sign/verify benchmarkssrc,lib: switch usages internal slot to a bitmask...rest is fixups and applying feedbackThe PR's changes UI is your friend, either filter commits, or filter files, or both, mark reviewed files as
Viewedto remember where you left off.Benchmark(s)
https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1833/
https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1834/
https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1835/
There's a ton of noise in this to conclude this isn't a performance regression. 🤞
Signed-off-by: Filip Skokan <panva.ip@gmail.com>